﻿using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AttendanceSysytem.Controls
{
    public partial class AttendanceMainPage : UserControl
    {
        public AttendanceMainPage()
        {
            InitializeComponent();
            InitAttendanceMenu();
        }

        Dictionary<int, Control> AttendanceMenuPages = new Dictionary<int, Control>();

        /// <summary>
        /// 初始化考勤系统菜单项
        /// </summary>
        /// <exception cref="NotImplementedException"></exception>
        private void InitAttendanceMenu()
        {
            AttendanceMenuPages.Add(1, new AttendancePage());
            AttendanceMenuPages.Add(2, new ScheduleTablePage());
            AttendanceMenuPages.Add(3, new EmployeePage());
            AttendanceMenuPages.Add(4, new AttendanceConfigPage());

            segmented1.SelectIndexChanged += Segmented1_SelectIndexChanged;
            segmented1.SelectIndex = 1;
        }

        private void Segmented1_SelectIndexChanged(object sender, AntdUI.IntEventArgs e)
        {
            pnlContent1.Controls.Clear();
            var item = segmented1.Items[segmented1.SelectIndex];
            var menuId = item.ID.ObjToInt();
            var page = AttendanceMenuPages[menuId];
            pnlContent1.Controls.Add(page);
            page.Dock = DockStyle.Fill;

        }
    }
}
